<script setup>
import { GetFormAPI, AddDataAPI, ADDAPI } from '@/api/system/form.js'

// import NewForm from '@/form/newForm.vue'

const route = useRoute()

// 状态 、标题
const state = reactive({
  isShow: false,
  isAddShow: false,
})

// 请求条件
const query = reactive({
  path: route.path + '/index'
})

// 自定义列表
const formList = ref([])

// 列表数据
const tableData = ref([])

// 获取列表数据
const getFormList = async () => {
  const { data: result } = await GetFormAPI(query)
  tableData.value = result
}
getFormList()

// 测试自定义表单
const test = async () => {
  state.isShow = true
  const { data: result } = await GetFormAPI(query)
  formList.value = result
}

const add = async () => {
  await ADDAPI()
}

</script>

<template>
  <div class="app-container">
    <el-button type="primary" @click="test">测试自定义表单</el-button>
    <el-table :data="tableData" style="width: 100%">
      <el-table-column prop="lable" label="名称" />
      <el-table-column prop="model" label="字段名" />
      <el-table-column label="是否必填">
        <template #default="{ row }">{{
          row.isRequired == 1 ? "必填" : "非必填"
        }}</template>
      </el-table-column>
      <el-table-column prop="type" label="类型">
        <template #default="{ row }">
          <p-tag v-if="row.type == 1" text="文本" />
          <p-tag v-if="row.type == 2" text="下拉" />
        </template>
      </el-table-column>
    </el-table>
    <p-dialog v-model="state.isShow">
      <template #body>
        <!-- <NewForm :data="formList" ref="NewFormRef" /> -->
      </template>
    </p-dialog>
  </div>
</template>
<style scoped lang='scss'>
</style>